<?php echo $this->load->view('_elements/registratednavigation'); ?>

<div id="content">

    <div id="centerbar">
        <div class="titlered"><?php echo $Title ?></div>
        <div id="tableblock" class="blockstyle">
            <table id="requestable" border="0" cellpadding="0" cellspacing="0" width="100%">
            <thead>
                <tr>
                        <th><?php echo $this->user_model->fields['referral_no']?></th>
                        <th><?php echo $this->user_model->fields['ref_status']?></th>
                        <th><?php echo $this->user_model->fields['ref_date_posted']?></th>
                        <th><?php echo $this->user_model->fields['ref_end_date']?></th>
                        <th><?php echo $this->user_model->fields['ref_abstract']?></th>
                        <th><?php echo $this->user_model->fields['ref_ask']?></th>
                        <th><?php echo $this->user_model->fields['ref_bids']?></th>
                        <th><?php echo $this->user_model->fields['ref_avg_bid']?></th>
                </tr>
            </thead>
            <tbody>
                <?php //pr($referrals);
                foreach($referrals as $key => $value) {
                   echo " <tr>
                            <td>".anchor('/user/referral_details/'.$value['ur_id'], $value['ur_id'])."</td>
                            <td>".anchor('/user/bids/'.$value['ur_id'], $status[$value['ur_status']])."</td>
                            <td>".$value['ur_date_posted']."</td>
                            <td>".$value['ur_end_date']."</td>
                            <td>".$value['ur_abstract']."</td>
                            <td>$".$value['ur_ask_price']."</td>
                            <td>".$value['ur_bid_num']."</td>
                            <td>$".$value['ur_bid_avg']."</td>
                        </tr>";
                } ?>
               </tbody>
            </table>
            <?php /*echo $this->pagination->create_links('HN Books');*/?>
        <?php /*echo $this->load->view('_elements/navigation'); */?>
        <!-- span id="lefttext" class="simpletext">Page</span -->
        </div>
    </div>
    <div id="post_new_request" class="blackbuttonstyle"><?=anchor('/user/post_request', 'Post New Referral Request');?></div>
    <?php echo $this->load->view('_elements/Followrefs'); ?>
</div>

<script type="text/javascript">

	var oTable;

	$(document).ready(function()
	{
		/* Init DataTables */
		oTable = $('#requestable').dataTable(
		{
            "sDom": '<"top"i>rt<"bottom"flp><"clear">',
			"aaSorting": [],
			"aoColumns": [
	  			{ "bSortable": true },
	  			null,
	  			null,
	  			null,
	  			null,
	  			null,
                null,
                null
	  		],

			"bPaginate": true,
			"bLengthChange": true,
			"bFilter": false,
			"bSort": true,
			"bInfo": false,
			"bAutoWidth": true,
			"bJQueryUI": true,
			"sPaginationType": "full_numbers"
		});

		$('#requestable_paginate').append('<span id="page_text" class="red">Page </span>');
    	$('#requestable_first, #requestable_previous, #requestable_next, #requestable_last').hide();
        $(".dataTables_paginate span span.fg-button.ui-button.ui-state-default").parent().attr('id','leftnavigation');
        
	});

	/*
	 * I don't actually use this here, but it is provided as it might be useful and demonstrates
	 * getting the TR nodes from DataTables
	 */
	function fnGetSelected( oTableLocal )
	{
		var aReturn = new Array();
		var aTrs = oTableLocal.fnGetNodes();

		for ( var i=0 ; i<aTrs.length ; i++ )
		{
			if ( $(aTrs[i]).hasClass('row_selected') )
			{
				aReturn.push( aTrs[i] );
			}
		}
		return aReturn;
	}

    
	</script>
